package com.cdu.guoxinan.www.smartcom.service.impl;

import com.cdu.guoxinan.www.smartcom.domian.dto.VisitorQueryDTO;
import com.cdu.guoxinan.www.smartcom.domian.pojo.Visitor;


import com.cdu.guoxinan.www.smartcom.mapper.VisitorMapper;
import com.cdu.guoxinan.www.smartcom.service.VisitorService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class VisitorServiceImpl implements VisitorService {
    @Resource
    private VisitorMapper visitorMapper;
    @Override
    public PageInfo<Visitor> queryPage(VisitorQueryDTO visitorQueryDTO) {
        PageHelper.startPage(visitorQueryDTO.getPage(), visitorQueryDTO.getLimit() );
        List<Visitor> list = visitorMapper.queryPage(visitorQueryDTO);
        PageInfo<Visitor> pageInfo = new PageInfo<>(list);
        return pageInfo;
    }

    @Override
    public boolean add(Visitor visitor) {
        int result = visitorMapper.add(visitor);
        return result > 0;
    }

    @Override
    public boolean update(Visitor visitor) {
        int result = visitorMapper.update(visitor);
        return result > 0;
    }

    @Override
    public boolean delete(Integer id) {
        int result = visitorMapper.delete(id);
        return result > 0;
    }

    @Override
    public boolean leave(Integer id) {
        int result = visitorMapper.leave(id);
        return result > 0;
    }
}
